//
//  PrivacyStatementViewController.m
//  CenturyInterconnection
//
//  Created by Tian Wei You on 16/5/16.
//  Copyright © 2016年 Shanghai DuRui Information Technology Company. All rights reserved.
//

#import "PrivacyStatementViewController.h"
#import "NSString+Common.h"

@interface PrivacyStatementViewController ()
@property(nonatomic,strong)NSString *contactStr;

@end

@implementation PrivacyStatementViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self getDatas];
    [self makeNaviButton];
}

-(void)makeNaviButton{
    
    self.title=@"ABOUT US";
    
    UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [leftButton setBackgroundImage:[UIImage imageNamed:@"nav_back"] forState:0];
    
    leftButton.frame=CGRectMake(0, 0, ACTUAL_WIDTH(23), ACTUAL_HEIGHT(23));
    
    [leftButton addTarget:self action:@selector(comeBack) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem*item= [[UIBarButtonItem alloc]initWithCustomView:leftButton];
    
    self.navigationItem.leftBarButtonItem=item;
}

#pragma mark 返回事件
-(void)comeBack{
    [self.navigationController popViewControllerAnimated:YES];
}
//测试
-(void)getDatas{
    // http://viprunningonline.com/api/index.php? main_page=privacy
    
    NSString*urlStrr=[NSString stringWithFormat:@"%@",HTTP_ADDRESS];
    NSDictionary*paramss=@{@"main_page":@"privacy"};
    HttpManager*managerr=[[HttpManager alloc]init];
    [managerr getDataFromNetworkNOHUDWithUrl:urlStrr parameters:paramss compliation:^(id data, NSError *error) {
        
        NSString*number=[NSString stringWithFormat:@"%@",data[@"status"]];
        
        if ([number isEqualToString:@"1"]) {
            self.contactStr=data[@"data"][@"content"];
            [self makeView];
        }
    }];
}

-(void)makeView{
    
    self.view.backgroundColor=[UIColor whiteColor];
    
    CGFloat height = MIN(999, [self.contactStr getHeightWithFont:[UIFont systemFontOfSize:18] constrainedToSize:CGSizeMake(300, CGFLOAT_MAX)]);//利用第三方工具算出内容所需高度
    
    UILabel *contactLabel=[[UILabel alloc]initWithFrame:CGRectMake(ACTUAL_WIDTH(10), ACTUAL_HEIGHT(74), KScreenWidth-ACTUAL_WIDTH(20), height)];
    contactLabel.text=self.contactStr;
//    contactLabel.backgroundColor=[UIColor yellowColor];
    contactLabel.numberOfLines=0;
    [self.view addSubview:contactLabel];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
